package com.sxz.sbs.module.client.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.client.view.AddStallView;
import com.sxz.sbs.module.sale.mode.StallTypeBean;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;
import java.util.List;

/**
 * 添加车位
 */

public class AddStallPresenter extends RxPresenter<AddStallView>{

    public void addStall(HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().addStall(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView){
                    @Override
                    public void onNext(String data) {
                        mView.onAddStallSuccess();
                    }
                })
        );
    }
    /**
     * 车位类型
     * @param map
     */
    public void getStallType (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getStallType(map)
                .compose(RxUtil.<List<StallTypeBean>>handleResult())
                .subscribeWith(new RxSubscriber<List<StallTypeBean>>(mView,true){
                    @Override
                    public void onNext(List<StallTypeBean> data) {
                        mView.onGetStallTypeSuccess(data);
                    }
                })
        );
    }
}
